﻿import gs.*;
import com.darronschall.DynamicRegistration;
import mx.transitions.easing.*;
import mx.utils.Delegate;
class cn.eminia.AS2.TwAll {
	function TwAll(a, b, c, d) {
		if (a == null) {
			throw new Error("大错，TwAll 没有 MC");
			return;
		}
		switch (b.toLowerCase()) {
		case 'listlee' :
			TwListLee(a, b, c, d);
			break;
		case 'list' :
			TwList(a, b, c, d);
			break;
		case 'pannel0' :
			pannel0(a, b);
			break;
		case 'pannel' :
			Tw021(a, b, c, d);
			break;
		case 'pannelv2' :
			Tw022(a, b, c, d);
			break;
		case 'form' :
			Tw052(a, b, c);
			trace('here');
			break;
		case 'roundbar' :
			Tw070(a, b, c, d);
			break;
		case 'doback' :
			Tw071(a, b, c, d);
			break;
		default :
			throw new Error("指定错");
		}
	}
	function TwListLee(arr, b, c, d) {
		if (arr.constructor == MovieClip) {
			var arr = cn.eminia.AS2.Util.orderBy('|', arr);
		}
		if (cn.eminia.AS2.Util.compareArray(c, [0, 1])) {
			for (var i = 0; i<arr.length; i++) {
				var aa = arr[i];
				aa._visible = true;
				aa._alpha = 0;
				TweenLite.to(aa, .6, {delay:.1*i, _alpha:100, _y:'-10'});
			}
		} else {
		}
	}
	function TwList(arr, b, c, d) {
		if (arr.constructor == MovieClip) {
			var arr = cn.eminia.AS2.Util.orderBy('|', arr);
		}
		if (cn.eminia.AS2.Util.compareArray(c, [0, 1])) {
			for (var i = 0; i<arr.length; i++) {
				var aa = arr[i];
				aa._visible = true;
				aa._alpha = 0;
				TweenLite.to(aa, .6, {delay:.1*i, _alpha:100});
			}
		} else {
		}
	}
	function pannel0(aa:MovieClip) {
		if (aa._xscale2 != null) { 
			TweenMax.to(aa, .1, {_xscale2:100, _yscale2:100, blurFilter:{blurX:0, blurY:0}});
		}
		aa._visible = true;
		aa._alpha = 100;
	}
	function Tw021(a:MovieClip, b, c, d) {
		if (cn.eminia.AS2.Util.compareArray(c, [1, 0])) {
			/*TweenLite.to(a, .4, {_alpha:0, onCompleteScope:a, onComplete:function () {
			a._visible = false;
			}});*/
			if (a._xscale2 == null) {
				DynamicRegistration.initialize(a);
				a.setRegistration(a._width/2, a._height/2);
			}
			TweenMax.to(a, .2, {_xscale2:90, _yscale2:90, blurFilter:{blurX:5, blurY:5}});
			if (d.onComplete != null) {
				d.scope = (d.scope == null) ? a : d.scope;
				TweenLite.to(a, .4, {overwrite:false, _alpha:0, onCompleteScope:this, onComplete:function () {
					var onOK = Delegate.create(d.scope, d.onComplete);
					trace(d.scope);
					onOK();
					a._visible = false;
				}});
			}
		} else {
			//a.gotoAndPlay(1) 
			a._visible = true;
			a._alpha = 0;
			/*TweenLite.to(a, .4, {_alpha:100});*/
			if (a._xscale2 == null) {
				DynamicRegistration.initialize(a);
				a.setRegistration(a._width/2, a._height/2);
			}
			a._xscale2 = 90;
			a._yscale2 = 90;
			TweenMax.to(a, .2, {_xscale2:100, _yscale2:100, blurFilter:{blurX:0, blurY:0}});
			TweenMax.to(a, .4, {overwrite:false, _alpha:100});
		}
	}
	function Tw022(a:MovieClip, b, c, d) {
		if (cn.eminia.AS2.Util.compareArray(c, [1, 0])) {
			if (d.onComplete != null) {
				d.scope = (d.scope == null) ? a : d.scope;
				TweenLite.to(a, .4, {_alpha:0, onCompleteScope:this, onComplete:function () {
					var onOK = Delegate.create(d.scope, d.onComplete);
					onOK();
					a._visible = false;
				}});
				return;
			}
			TweenLite.to(a, .4, {_alpha:0, onCompleteScope:this, onComplete:function () {
				a._visible = false;
			}});
		} else {
			//a.gotoAndPlay(1) 
			a._visible = true;
			a._alpha = 0;
			TweenLite.to(a, 1.4, {_alpha:100});
		}
	}
	function Tw052(arr, b, c) {
		if (arr.constructor == MovieClip) {
			var arr = cn.eminia.AS2.Util.orderBy('|', arr);
			//trace('arr -) '+arr);
		}
		//trace('arr -) '+arr);              
		if (cn.eminia.AS2.Util.compareArray(c, [0, 1])) {
			for (var i = 0; i<arr.length; i++) {
				var ooo = arr[i];
				ooo._alpha = 0;
				ooo._x -= 20;
				TweenLite.to(arr[i], .6, {delay:.15*i, _x:ooo._x+20, _alpha:100});
			}
		} else {
			for (var i = 0; i<arr.length; i++) {
				var ooo = arr[i];
				ooo._alpha = 0;
				ooo._x += 20;
				TweenLite.to(arr[i], .6, {delay:.15*i, _x:ooo._x-20, _alpha:100});
			}
		}
	}
	function Tw070(a:MovieClip, b, c, d) {
		if (d.dir == '-') {
			if (a.mm.constructor == MovieClip) {
				//
				TweenLite.to(a.mm, c, {_width:0});
				a.onEnterFrame = function() {
					trace(this.mm._width);
					trace(this.rr._x);
					this.rr._x = this.mm._width+this.mm._x-1;
				};
			} else if (a.bar.constructor == MovieClip) {
				/*if (a.msk == null) {
				throw new Error('大错  没有 MC msk ');
				} */
				TweenLite.to(a.bar, c, {_x:a.bar._x-a.bar._width, onComplete:Delegate.create(d.onCompleteScope, function () {
					d.onComplete();
				}), ease:None.easeIn});
			}
		}
	}
	function Tw071(a:MovieClip, b, c, d) {
		if (a.constructor != MovieClip) {
			trace('大错  ');
			return;
		}
		//var dd=_root.getNextHighestDepth();                    
		//_root.createEmptyMovieClip('')
		a.onEnterFrame = Delegate.create(this, function () {
			a.prevFrame();
			if (a._currentframe == 1) {
				delete a.onEnterFrame;
				c.onComplete();
			}
		});
	}
}
